package com.mspbots.cw.amqp.receivers;

import com.mspbots.cw.amqp.BaseReceiver;
import com.mspbots.cw.amqp.model.ExceptionLog;
import lombok.extern.log4j.Log4j2;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;


/**
 * com.mspbots.core.amqp.receivers.ExceptionLogReceiver
 *
 * @author Alex bob(https://github.com/vnobo)
 * @date Created by 2019/10/14
 */
@Log4j2
@Component
public class ExceptionLogReceiver extends BaseReceiver {

    @RabbitListener(queues = "exception.log")
    public void processMessage(ExceptionLog content) {
        log.debug("exception.log is {}", content.getMsg());
        this.databaseClient.insert().into(ExceptionLog.class)
                .using(content).fetch().rowsUpdated().block();
    }
}
